<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
		<title>发布作业</title>
		<link rel="stylesheet" href="__PUBLIC__/css/weui.min.css" />
		<link rel="stylesheet" href="__PUBLIC__/css/example.css" />
		<script src="__PUBLIC__/js/zepto.min.js"></script>
		<script src="__PUBLIC__/js/jquery-weui.js"></script>
		<script src="__PUBLIC__/js/jquery.min.js"></script>
		<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	</head>

	<body>
		<div class="ramdon">
			<div class="hd">
				<h1 class="page_title">发布作业</h1>
			</div>
			<div class="bd">
				<!--选填信息start-->
				<div class="weui_cells_title">作业名称</div>
				<div class="weui_cells weui_cells_form">
					<div class="weui_cell">
						<div class="weui_cell_hd">
							<label class="weui_label">名称</label>
						</div>
						<div class="weui_cell_bd weui_cell_primary">
							<input class="weui_input" name="testName" type="text" value="随堂测试" />
						</div>
					</div>
				</div>
				<div class="weui_cells_title">开启班级</div>
				<div class="weui_cells weui_cells_checkbox">
					<?php if(is_array($banji)): foreach($banji as $key=>$banji): ?><label class="weui_cell weui_check_label" for="<?php echo ($banji["class"]); ?>">
               		<div class="weui_cell_hd">
                 	   <input type="checkbox" class="weui_check" name="checkbox1" id="<?php echo ($banji["class"]); ?>" value="<?php echo ($banji["class"]); ?>">
                 	   <i class="weui_icon_checked"></i>
               		</div>
                	<div class="weui_cell_bd weui_cell_primary">
                    	<p><?php echo ($banji["class"]); ?></p>
                	</div>
           		</label><?php endforeach; endif; ?>

					<label class="weui_cell weui_check_label" for="s12">
                	<div class="weui_cell_hd">
                    	<input type="checkbox" name="checkbox1" class="weui_check" id="s12" value="工商1401班">
                    	<i class="weui_icon_checked"></i>
                	</div>
                	<div class="weui_cell_bd weui_cell_primary">
                    	<p>工商1401班</p>
               		</div>
            	</label>
					<label class="weui_cell weui_check_label" for="s13">
                	<div class="weui_cell_hd">
                    	<input type="checkbox" name="checkbox1" class="weui_check" id="s13" value="营销1401班">
                    	<i class="weui_icon_checked"></i>
                	</div>
                	<div class="weui_cell_bd weui_cell_primary">
                    	<p>营销1401班</p>
               		</div>
            	</label>
				</div>
				<!--选填信息end-->
				<div class="weui_btn_area">
					<input class="weui_btn weui_btn_primary" id="submit" type="submit" value="发布作业" />
				</div>
			</div>
		</div>
		<div class="weui_msg" style="display: none;">
			<div class="weui_icon_area do_success"><i class="weui_icon_success weui_icon_msg"></i></div>
			<div class="weui_text_area">
				<h2 class="weui_msg_title do_success">修改成功</h2>
				<p class="weui_msg_desc"></p>
			</div>
			<div class="weui_opr_area">
				<p class="weui_btn_area">
					<a class="weui_btn weui_btn_primary" id="yes">确定</a>
				</p>
			</div>
			<div class="weui_extra_area">
				<a href="javascript:;">查看详情</a>
			</div>
		</div>

	</body>

</html>

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
	function isNumber(theNum) {
		if (theNum == "")
			return false;
		for (var i = 0; i < theNum.length; i++) {
			oneNum = theNum.substring(i, i + 1);
			if (oneNum < "0" || oneNum > "9")
				return false;
		}
		return true;
	}
	var questionId = "";
	$("#submit").click(function(event) {
		var testName = $("input[name='testName']").val();
		for (var i = 0; i < localStorage.length; i++) {
			if (isNumber(localStorage.key(i))) {
				questionId += localStorage.key(i) + "_";
			}
		}
		var onClass = "";
		$(":checked").each(function() {
			if ($(this).is(":checked")) {
				onClass += $(this).val() + "_";
			}
		});
		url = "<?php echo U('ClassTest/handleSubmitQues');?>";
		data = {
			testName: testName,
			onClass: onClass,
			questionId: questionId
		}
		$.post(url, data,
			function(data, state) {
				localStorage.clear();
				$('.ramdon').hide();
				$(".weui_msg").show();
			}
		);
	});
	$("#yes").click(function(e) {
		wx.closeWindow();
	});
</script>